package com.example.invoice_contrast.utils;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class DateUtils {
    public static String dateUtily(){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

        // 获取当前日期
        Date currentDate = new Date();

        // 创建一个Calendar实例
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(currentDate);

        // 将日期向前推1天
        calendar.add(Calendar.DAY_OF_MONTH, -1);

        // 获取前一天的日期
        Date previousDate = calendar.getTime();

        // 格式化前一天的日期
        String previousDateString = sdf.format(previousDate);

        System.out.println("前一天的日期是 : " + previousDateString);
        return previousDateString;

    }
}
